package pay.weixin.demo;

/**
 * Created by Administrator on 2017/9/5.
 */
public class Demo {


//    private static void refund(String orderNo, float money) {
//        String result = "";
//        if (StringUtils.isEmpty(result)) {
//            String appid = WeixinConfig.appid;
//            String mch_id = WeixinConfig.mch_id;
//            String nonce_str = RandCharsUtils.getRandomString(32);
//            String out_refund_no = "T" + orderNo;
//            int total_fee = (int) (money * 100);//单位为分
//            int refund_fee = (int) (money * 100);
//            String op_user_id = WeixinConfig.mch_id;//操作员帐号, 默认为商户号
//
//            SortedMap<Object, Object> parameters = new TreeMap<Object, Object>();
//            parameters.put("appid", appid);
//            parameters.put("mch_id", mch_id);
//            parameters.put("nonce_str", nonce_str);
//            parameters.put("out_trade_no", orderNo);
//            parameters.put("out_refund_no", out_refund_no);
//            parameters.put("total_fee", total_fee);
//            parameters.put("refund_fee", refund_fee);
//            parameters.put("op_user_id", op_user_id);
//
//            String sign = WXSignUtils.createRefundSign("UTF-8", parameters);
//            System.out.println("签名是：" + sign);
//
//            WXPayRefund refund = new WXPayRefund();
//            refund.setAppid(appid);
//            refund.setMch_id(mch_id);
//            refund.setNonce_str(nonce_str);
//            refund.setOp_user_id(op_user_id);
//            refund.setOut_refund_no(out_refund_no);
//            refund.setRefund_fee(refund_fee);
//            refund.setSign(sign);
//            refund.setTotal_fee(total_fee);
//            refund.setOut_trade_no(orderNo);
//
//            //构造xml参数
//            String xmlInfo = HttpXmlUtils.getRefundXmlInfo(refund);
//            System.out.println("xml是：" + xmlInfo);
//            String wxUrl = WeixinConfig.refund_URL;
//            String weixinPost = null;
//            try {
//                weixinPost = ClientCustomSSL.doRefund(wxUrl, xmlInfo).toString();
//            } catch (Exception e) {
//                e.printStackTrace();
//
//            }
//            System.out.println(weixinPost);
//
////            WXPayRefundResult refundResult = WeixinPay.getUnifiedorderResult(weixinPost);
////
////            if("SUCCESS".equalsIgnoreCase(refundResult.getResult_code())){
////                result = "200";
////                System.out.println("==========处理退款成功==========");
////            }else{
////                result = refundResult.getReturn_msg();
////            }
//        }
//    }


//    public static void main(String[] args) throws Exception {
//        refund("1708292346564051", 0.01f);
//    }


}
